﻿using HighPerformanceLog.V2;
using System.IO;


namespace ProcessBarDemo.UpdateFramework
{
    class FileMerger
    {
        public static void Merge(string[] partFiles, string finalFile)
        {
            HWLogger.InfoLog($"开始合并 {partFiles.Length} 个分片为：{finalFile}");
            using (var output = new FileStream(finalFile, FileMode.Create, FileAccess.Write))
            {
                foreach (var part in partFiles)
                {
                    HWLogger.DebugLog($"合并分片：{part}");
                    using (var input = new FileStream(part, FileMode.Open, FileAccess.Read))
                    {
                        input.CopyTo(output);
                    }

                    File.Delete(part);
                }
            }
            HWLogger.InfoLog($"合并完成：{finalFile}");
        }
    }
}
